package cn.lds.healthexamspringboot.dto;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

@AllArgsConstructor
@Getter
@ToString
public class ResponseDTO<T> {

    private Integer code;
    private String msg;
    private T data;

    public static ResponseDTO buildSuccess(){
        return new ResponseDTO<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), null);
    }

    public static ResponseDTO buildSuccess(Object data){
        return new ResponseDTO<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), data);
    }

    public static ResponseDTO buildError(){
        return new ResponseDTO<>(ResponseEnum.ERROR.getCode(), ResponseEnum.ERROR.getMsg(),null);
    }

    public  static ResponseDTO buildError(String msg){
        return new ResponseDTO<>(ResponseEnum.ERROR.getCode(),msg,null);
    }




}
